package hy.mvpbeam.persenter.activitypersenter;

import android.support.annotation.NonNull;
import android.util.Log;

import com.jude.beam.expansion.data.BeamDataActivity;
import com.jude.beam.expansion.data.BeamDataActivityPresenter;
import com.jude.beam.expansion.list.BeamListActivityPresenter;

import hy.mvpbeam.activity.PictureActivty;
import hy.mvpbeam.activity.PictureListActivity;
import hy.mvpbeam.model.PictureModel;
import hy.mvpbeam.model.bean.PictureBean;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by hy on 2016/10/26.
 */

public class PictureActivityPresenter extends BeamDataActivityPresenter<PictureActivty, PictureBean> {
    private static final String TAG = PictureActivityPresenter.class.getSimpleName();

    @Override
    protected void onCreateView(@NonNull PictureActivty view) {
        super.onCreateView(view);

        loaddata();

    }

    public  void loaddata(){
        PictureModel.getInstance().getPictureList(new Callback<PictureBean>() {
            @Override
            public void onResponse(Call<PictureBean> call, Response<PictureBean> response) {
                Log.d(TAG, "onResponse: " + response.body().toString());
                //数据获取完毕后，将数据填充到view
              getDataSubscriber().onNext(response.body());
            }


            @Override
            public void onFailure(Call<PictureBean> call, Throwable t) {
                Log.d(TAG, "onFailure: ");
            }
        });
    }
}
